package YAVMM::Error;
use Moose;
use MooseX::Storage;

with 'YAVMM::Error::Role';

with Storage('format' => 'JSON');

use overload ('""' => 'stringify');

has 'error' => (
    is       => 'rw',
    isa      => 'Str',
    reader   => '_get_error',
    writer   => '_set_error',
    required => 1,
);

has 'code' => (
    is       => 'rw',
    isa      => 'Int',
    writer   => '_set_code',
);

sub error {
    my $self = shift;
    return $self->_get_error;
}

sub stringify {
    my $self = shift;
    return $self->_get_error."\n";
}

sub TO_JSON {
    return $_[0]->freeze;
}

no Moose;
__PACKAGE__->meta->make_immutable;
1;
